<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="/js/jquery-1.8.0.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css">
    <script type="text/javascript" src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>

    <script src="http://api.map.baidu.com/api?v=2.0&ak=sMCT4akUm7o8XeiByYZc83G1QXgI0Z5c" type="text/javascript"></script>
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
    <!-- (Optional) Latest compiled and minified JavaScript translation files -->
    <script type="text/javascript" src="/js/kindeditor-4.1.10/kindeditor-all.js"></script>
    <link rel="stylesheet" href="/js/kindeditor-4.1.10/themes/default/default.css" type="text/css"></link>
    <link rel="stylesheet" href="/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css">
    <script src="/js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script src="/js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="http://api.map.baidu.com/api?v=2.0&ak=xD0rFVX1eOML4bG6Mr3hGQvqBkDkyAKg"></script>
    <link rel="stylesheet" href="/js/LoginJsp/layui/css/layui.css">
    <script src="/js/LoginJsp/layui/layui.js"></script>
    <link rel="stylesheet" href="/layer/mobile/need/layer.css">
    <script src="/layer/mobile/layer.js"></script>
    <link rel="stylesheet" href="/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/layui/css/layui.mobile.css">
    <script src="/layui/layui.all.js"></script>
</head>
<body>
<form class="form-horizontal" id="addformOne" role="form">
    <input id="userids" name="id" hidden></br>
    <fieldset>
        <legend>微博信息</legend>
        <div class="form-group" style="margin-left:150px">
            <label class="col-sm-2 control-label" for="ds_username">标题</label>
            <div class="col-sm-4">
                <input type="text" hidden id="userId" name="bzname"><br>
                <input class="form-control" id="ds_username" name="bkname" type="text" placeholder="请输入标题"/>
            </div>
        </div>
    </fieldset>
    <fieldset>
        <div class="form-group" style="margin-left:150px">
            <label class="col-sm-2 control-label" for="ds_username">类型</label>
            <div class="col-sm-4">
                <select id="lunch" class="selectpicker" name="tablename" data-live-search="true" title="Please select a lunch ...">
                    <option value="b_keji">科技</option>
                    <option value="b_caijing">财经</option>
                    <option value="b_tiyu">体育</option>
                    <option value="xzh_military">军事</option>
                    <option value="xzh_parenting">育儿</option>
                    <option value="xzh_constellation">星座</option>
                    <option value="h_car">汽车</option>
                    <option value="h_house">房产</option>
                    <option value="h_cate">美食</option>
                </select>
            </div>
        </div>
    </fieldset>
    <fieldset>
        <div class="form-group" style="margin-left:150px">
            <label class="col-sm-2 control-label" for="ds_username">发布时间</label>
            <div class="col-sm-4">
                <input class="form-control" readonly="readonly" name="releaseTime" id="createtime" type="text" placeholder="请选择发布时间"/>
                <input type="text" value="0" name="state" hidden>
            </div>
        </div>
    </fieldset>
    <fieldset>
        <div class="form-group" style="margin-left:150px">
            <label class="col-sm-2 control-label" for="ds_username">位置</label>
            <div class="col-sm-4">
                <input class="form-control" id="dingwei" name="spaces" readonly="readonly" type="text"  placeholder="点击获取位置"/>
                <button type="button" class="btn btn-info"  onclick="location.href='/view/toView?view=wwwwww'">查看地图</button>
                <div id="allmap"></div>
            </div>
        </div>
    </fieldset>
    <fieldset>
        <legend>微博正文</legend>
        <div class="form-group" style="margin-left:200px">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <textarea id="content1" name="wenzhang"  style="width:800px;height:350px;"></textarea>
        </div>
    </fieldset>
</form>
    <fieldset>
        <div class="form-group" style="margin-left:500px">
            <div class="col-sm-4">
                <button type="button" class="btn btn-primary" onclick="addWB()">发布</button>
                <button type="button" class="btn btn-danger" onclick="toRest()">重置</button>
            </div>
        </div>
    </fieldset>
</body>
<script>
    function addWB(){
        //addformOne
        $.ajax({
            url:"/add/addwb",
            type:"POST",
            data:$("#addformOne").serialize(),
            success:function(pageUtil){
                if(pageUtil==1){
                    layer.alert("已加入定时任务");
                    toloda();
                }else{
                    //ErroAlert('登录失败,密码或者账号不正确');
                    layer.alert("系统繁忙，请稍后重试");
                    window.location.reload();
                }
            },
            error:function(){
                layer.alert('系统繁忙，请稍后重试');
            }
        });

    }
    $(function () {
        goTo();
        textwenben();
        $("#createtime").datetimepicker({
            format: "yyyy-mm-dd hh:mm:ss",
            autoclose: true,
            todayBtn: true,
            todayHighlight: true,
            showMeridian: true,
            startDate:new Date(),
            pickerPosition: "bottom-left",
            language: 'zh-CN',//中文，需要引用zh-CN.js包
            startView: 2,//月视图
            minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
        });
    })
    //加载富文本
    function textwenben() {
        //编辑器
        var editor = null;
        KindEditor.ready(function (K) {//将编辑器添加到文档中
            editor = K.create('#content1', {
                cssPath: '/js/kindeditor-4.1.10/plugins/code/prettify.css',//指定编辑器iframe document的CSS文件，用于设置可视化区域的样式。
                uploadJson: '/js/kindeditor-4.1.10/jsp/upload_json.jsp', //指定上传文件的服务器端程序。
                fileManagerJson: '/js/kindeditor-4.1.10/jsp/file_manager_json.jsp',//指定浏览远程图片的服务器端程序。
                allowFileManager: true,  //true时显示浏览远程服务器按钮 ;默认值: false
                afterBlur: function () {
                    this.sync();
                }
            });

        });
    }
 function toRest(){
        location.reload();
 }
 function toloda(){

     window.location.reload();
 }
    //登录转换页面
    function goTo(){
        $.ajax({
            type : "get",
            url : "/user/checkUser",
            success : function(user) {
                if(user!=null){
                    $("#userId").val(user.bzname);
                    $("#userids").val(user.bzid)
                }else{
                    window.location.reload();
                }
            },
            error : function() {
                layer.alert("請求失敗");
            }
        });
    }
</script>
<script>
    $("#dingwei").click(function(ev){
        $(ev.currentTarget).text("正在获取位置......");
        //创建百度地图控件
        var geolocation = new BMap.Geolocation();
        geolocation.getCurrentPosition(function(r){
            if(this.getStatus() == BMAP_STATUS_SUCCESS){
                //以指定的经度与纬度创建一个坐标点
                var pt = new BMap.Point(r.point.lng,r.point.lat);
                //alert(r.point.lng+"..."+r.point.lat);
                //创建一个地理位置解析器
                var geoc = new BMap.Geocoder();
                geoc.getLocation(pt, function(rs){//解析格式：城市，区县，街道
                    var addComp = rs.addressComponents;
                    $("#dingwei").val(addComp.city + ", " + addComp.district + ", " + addComp.street);
                });
            }
            else {
                $("#dingwei").val('定位失败');
            }
        },
            {
                enableHighAccuracy: true
            })//指示浏览器获取高精度的位置，默认false
    });
</script>
</html>